package main

import (
	"time"
	"math/rand"
)

func CreateFoodOnMap(a [][n]int) {
	for !GAME_OVER_BOOL_FLAG {
		createFoodOnMapRun(a)
		time.Sleep(time.Second)
	}
}

func createFoodOnMapRun(a [][n]int) {
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if (a[i][j] == mvFoodApple) {
				return
			}
		}
	}
	for {
		random := rand.New(rand.NewSource(time.Now().UnixNano()))
		x := 4 + random.Intn(n - 8)
		y := 4 + random.Intn(n - 8)
		if (a[x][y] == mvSpace) {
			a[x][y] = mvFoodApple
			return
		}
	}
}
